package com.realtyManage.springboot.Service.impl;

import com.realtyManage.springboot.Dao.AnnouncementRepository;
import com.realtyManage.springboot.Model.Do.Announcement;
import com.realtyManage.springboot.Service.IAnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * AnnouncementServiceImpl
 *
 * @Author 杭州素色网络科技有限公司
 * @Date 2019/5/4
 **/
@Service
@Transactional
public class AnnouncementServiceImpl implements IAnnouncementService{
    @Autowired
    private AnnouncementRepository announcementRepository;

    @Override
    public boolean insert(Announcement announcement) {
        if(announcementRepository.save(announcement)!=null){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public List<Announcement> findByStateAndTypeGatherThanEqual(int state, int type) {
        return announcementRepository.findByStateAndTypeGreaterThanEqualLimit(state,type);
    }

    @Override
    public List<Announcement> findByStateAndType(int state, int type) {
        return announcementRepository.findByStateAndType(state,type);
    }

    @Override
    public Announcement getOne(int id) {
        return announcementRepository.getOne(id);
    }
}
